﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.IO;
using System.Reflection;
using AMStudio.Script;
using System.Data;

namespace AMStudio.Common
{
    public static class TranslationDB
    {
        private static TranslationTagDAL translationTagDB = new TranslationTagDAL();
        public static Dictionary<string, TranslationItem> TranslationTags;
        public static void Init()
        {
            try
            {
                TranslationTags = translationTagDB.GetAllTranslationItems();
            }
            catch (Exception ex)
            {
                throw new Exception("TranslationDB Init Error:" + ex.Message);
            }
        }

        public static void Add(TranslationItem item)
        {
            if (!TranslationTags.ContainsKey(item.Source))
            {
                translationTagDB.Add(item);
                TranslationTags.Add(item.Source, item);
            }
        }

        public static void Update(TranslationItem item)
        {
            //if (UserTags.ContainsKey(user.UserName))
            //{
            translationTagDB.Update(item);
            //}
        }

        public static void Delete(string source)
        {
            if (TranslationTags.ContainsKey(source))
            {
                translationTagDB.Delete(source);
                TranslationTags.Remove(source);
            }
        }
   }
}
